#pragma once
#include <windows.h>
#include <mmsystem.h>
#include <stdio.h>

#include <d3d9.h>
#include <d3dx9.h>
#include <tchar.h>
#include <vector>

using namespace std;


#define FREEKEY	0x10
#define PULLKEY	0x20
#define PUSHKEY	0x40
#define HOLDKEY	0x80

#define SAFE_ZERO(A)				{ A = 0; }
#define SAFE_NEW(A, B)				{ if (!A) A = new B; }
#define SAFE_DEL(A)					{ if (A) delete A; (A)=NULL; }
#define SAFE_ARRAY_NEW(A, B, C)		{ if (!A && C) A = new B[C]; }
#define SAFE_ARRAY_DEL(A)			{ if (A) delete [] A; (A)=NULL; }
#define SAFE_RELEASE(A)				{ if(A) { (A)->Release(); (A)=NULL; } }
#define NEW_CLEAR( A, B )			{ if (!A) A = new B; if(A) memset( A, 0, sizeof(B) ); };
#define NEW_ARRAY_CLEAR( A, B, C )	{ if (!A && C) A = new B[C]; if(A) memset( A, 0, sizeof(B)*C ); };
